﻿using System;
using System.Collections.Generic;
using System.IO;
using ProjScan.Modules;
using ProjScan.RecordManager.AssetData;
using ProjScan.Tools;
using UnityEditor;
using UnityEngine;

namespace ProjScan.RecordManager
{
	// Token: 0x02000277 RID: 631
	internal class GameObjectRecordManager : RecordManagerBase<GameObjectAssetData>
	{
		// Token: 0x060010D0 RID: 4304 RVA: 0x0004DE24 File Offset: 0x0004C024
		public override void PrepareAssets()
		{
			this.datas = new List<GameObjectAssetData>();
			int num = AssetPathManager.Instance.prefabPathList.Length;
			for (int i = 0; i < num; i++)
			{
				bool isEditor = Singleton<ScanInfo>.Instance.isEditor;
				if (isEditor)
				{
					EditorUtility.DisplayProgressBar("Proj Scan [" + this.TableTag + "]", string.Concat(new string[]
					{
						"Preparing ",
						this.TableTag,
						"(",
						this.datas.Count.ToString(),
						")..."
					}), (float)i * 1f / (float)num);
				}
				bool flag = i % 100 == 0;
				if (flag)
				{
					ToolsHelper.GC();
				}
				string text = AssetPathManager.Instance.prefabPathList[i];
				this.ActiveAllRecord();
				bool flag2 = this.CheckAssetPathRules(text);
				if (flag2)
				{
					GameObject gameObject = AssetDatabase.LoadAssetAtPath(text, typeof(GameObject)) as GameObject;
					bool flag3 = gameObject != null;
					if (flag3)
					{
						int id = AssetPathManager.Instance.GetID(Path.GetDirectoryName(text));
						try
						{
							MeshRenderer[] componentsInChildren = gameObject.GetComponentsInChildren<MeshRenderer>();
							SkinnedMeshRenderer[] componentsInChildren2 = gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
							bool flag4 = (componentsInChildren != null && componentsInChildren.Length != 0) || (componentsInChildren2 != null && componentsInChildren2.Length != 0);
							if (flag4)
							{
								GameObjectAssetData gameObjectAssetData = new GameObjectAssetData(id, gameObject, text);
								gameObjectAssetData.id = this.datas.Count;
								this.ValidateAsset(gameObjectAssetData);
								gameObjectAssetData.Reset();
								this.datas.Add(gameObjectAssetData);
								bool flag5 = this.datas.Count % 100 == 0;
								if (flag5)
								{
									ToolsHelper.GC();
								}
							}
						}
						catch (Exception ex)
						{
							ScanLog.Instance.LogInfo(ScanLog.LogLevel.EXCEPTION, Module.Basic_Assets_Check, this.TableTag, string.Concat(new string[]
							{
								(ex.GetType() == null) ? null : ex.GetType().ToString(),
								"\n",
								ex.Message,
								"\n",
								ex.StackTrace
							}));
						}
					}
				}
			}
		}

		// Token: 0x17000375 RID: 885
		// (get) Token: 0x060010D1 RID: 4305 RVA: 0x0004E064 File Offset: 0x0004C264
		public override string TableTag
		{
			get
			{
				return "mesh_renderer_prefab";
			}
		}
	}
}
